<template>
		<view class="navbar" >
			<!-- 带返回按钮 -->
			<u-navbar :fixed="true" title=" " @leftClick="xz_back()" :safeAreaInsetTop="true" :bgColor="bg"
				title-color="white" v-if="have_back">
				<view class="u-nav-slot" slot="left">
					<u-icon  color="#ffffff" name="arrow-left" size="19"></u-icon>
				</view>
				<view class="title" slot="center">
					{{title}}
				</view>
			</u-navbar>
			<!-- 带回首页按钮 -->
		<!-- 	<u-navbar :fixed="true" title=" " @leftClick="xz_home('index')" :safeAreaInsetTop="true"
				:bgColor="bg" title-color="white"  v-if="!have_prev&&have_back">
				<view class="u-nav-slot" slot="left">
					<u-icon  color="#ffffff" name="home" size="20"></u-icon>
				</view>
				<view class="title" slot="center">
					{{title}}
				</view>
			</u-navbar> -->
			<!-- 不带返回按钮 -->
			<u-navbar :fixed="true" title=" " :safeAreaInsetTop="true"
				:bgColor="bg" title-color="white" v-if="!have_back">
				<view class="u-nav-slot" slot="left"></view>
				<view class="title" slot="center">
					{{title}}
				</view>
			</u-navbar>
			
			<u-navbar :fixed="true" title=" " :safeAreaInsetTop="true"
				:bgColor="bg" title-color="white" v-if="have_set">
				<view class="u-nav-slot" slot="left"></view>
				<view class="u-nav-slot" slot="right">
					<u-icon  color="#ffffff" name="setting" size="20"></u-icon>
				</view>
				<view class="title" slot="center">
					{{title}}
				</view>
			</u-navbar>
			
			<u-navbar :fixed="true" title=" " @rightClick="right_fun" :safeAreaInsetTop="true"
				:bgColor="bg" title-color="white" v-if="right_text">
				<view class="u-nav-slot" slot="left"></view>
				<view class="u-nav-slot" slot="right">
					<view class="right_text">
						{{right_text}}
					</view>
				</view>
				<view class="title" slot="center">
					{{title}}
				</view>
			</u-navbar>
			
			<!-- //这只自定义顶部栏高度 -->
			
			<!-- <view style="height: 44px;background: #3688FF;"></view> -->
		</view>
</template>
<script>
	export default {
		props: {
			title:{ type : String,  default : '' },
			have_back:{ type : Boolean,  default : true },
			bg:{type:String,default:'rgb(131,28,25)'},
			have_set:{ type : Boolean,  default : false },
			right_text:{ type : String,  default : '' },
			right_fun:{
            type: Function,
                  default: () => {
                    return Function;
             },
        },
		},
		data() {
			return {
				have_prev: true, //是否可以放回上一页
			}
		},
		onLoad(e) {
			
		
		},
		created: function() {
			let pages = getCurrentPages(); //获取所有页面栈实例列表
			let prevPage = pages[pages.length - 2]; //上一页页面实例
			// 没有上一页
			if (prevPage) {
				this.have_prev = true;
			} else {
				this.have_prev = false;
			}
			console.log('有没有上一页',this.have_prev);
		}
	}
</script>
<style lang="scss" scoped>
	/* //自定义顶部栏 */
	.navbar {
		font-size: 30rpx;
		/deep/.title {
			color: #fff;
		}
		/deep/.u-icon {
			padding: 10rpx;
			border-radius: 50%;
			// background:rgba(35 ,159 ,229,0.85);
		}
		.right_text{
			color: #fff;
		}
	}
	.have_bg{
		background: red;
	}
</style>
